home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-02-07 | 3.4 KB | 131 lines | [TEXT/MPS ] |
- { Miscellaneous routines used with the video XCMDs.
-
- This file in included in the other video XCMD source code files -- i.e., it is not compiled and
- linked separately. It contains a variety of useful utility routines.
-
- Copyright © 1987,88 Apple Computer, Inc.
-
- Initial coding 9/87 by Harry Chesley.
- }
-
- procedure GetStrGlobal(name: str255; var glob: str255);
- { Set glob to the global string specified by name. }
-
- var globHand: Handle;
-
- begin
- globHand := GetGlobal(name);
- if globHand = nil then glob := ''
- else
- begin
- ZeroToPas(globHand^,glob);
- DisposHandle(globHand);
- end;
- end;
-
- function GetLongGlobal(name: str255): longInt;
- { Return the global string specified by name, interpreted as a long integer. }
-
- var globStr: str255;
-
- begin
- GetStrGlobal(name,globStr);
- GetLongGlobal := StrToLong(globStr);
- end;
-
- procedure SetStrGlobal(name: str255; glob: str255);
- { Set the global string specified by name to glob. }
-
- var globHand: Handle;
-
- begin
- globHand := PasToZero(glob);
- SetGlobal(name,globHand);
- DisposHandle(globHand);
- end;
-
- procedure SetLongGlobal(name: str255; globLong: longInt);
- {Set the global string specified by name to a string that represents the number in globLong. }
-
- var globStr: str31;
-
- begin
- globStr := LongToStr(globLong);
- SetStrGlobal(name,globStr);
- end;
-
- procedure GetStrParm(n: integer; var str: str255);
- { Get the nth parameter into str. }
-
- begin
- ZeroToPas(paramPtr^.params[n]^,str);
- end;
-
- function GetLongParm(n: integer): longInt;
- { Return the nth parameter string, interpreted as a long integer. }
-
- var str: str255;
-
- begin
- ZeroToPas(paramPtr^.params[n]^,str);
- GetLongParm := StrToNum(str);
- end;
-
- function EvalStr(expr: str255): str255;
- { Evaluate the expression expr and return the resulting string. }
-
- var theResultHandle: Handle;
- theResultString: str255;
-
- begin
- { Evaluate the expression into a zero-terminated handle. }
- theResultHandle := EvalExpr(expr);
- { Check for user abort (HyperCard returns 1 if the user typed command-period; this is
- an undocuments but very usefull feature). }
- if paramPtr^.result <> xresSucc then Fail('abort');
- { Check for nil return. }
- if theResultHandle <> nil then
- begin
- { If not nil, convert it to a Pascal string. }
- ZeroToPas(theResultHandle^,theResultString);
- DisposHandle(theResultHandle);
- EvalStr := theResultString;
- end
- { If nil, return an empty string. }
- else EvalStr := '';
- end;
-
- procedure EvalAndDispose(expr: str255);
- { Evaluate the expression expr and throw away the result -- useful when you're only interested in the side-effects. }
-
- var theResultHandle: Handle;
-
- begin
- theResultHandle := EvalExpr(expr);
- { Check for user abort (HyperCard returns 1 if the user typed command-period; this is
- an undocuments but very usefull feature). }
- if paramPtr^.result <> xresSucc then Fail('abort');
- if theResultHandle <> nil then DisposHandle(theResultHandle);
- end;
-
- procedure videoCmd(cmd, parms: str255);
- { Send a command to the currently selected video driver. }
-
- var str: str255;
-
- begin
- GetStrGlobal('typeOfVideo',str);
- if str <> '' then EvalAndDispose(Concat('vidDrvr',str,'("',cmd,'",',parms,')'));
- end;
-
- function videoFunc(cmd, parms: str255): str255;
- { Call a function in the currently selected video driver. }
-
- var str: str255;
-
- begin
- GetStrGlobal('typeOfVideo',str);
- if str <> '' then videoFunc := EvalStr(Concat('vidDrvr',str,'("',cmd,'",',parms,')'))
- else videoFunc := '';
- end;
-